/*
 * This file is part of JContextFree.
 *
 * JContextFree is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * JContextFree is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with JContextFree.  If not, see <http://www.gnu.org/licenses/>.
 */

package it.enricod.jcontextfree;

import it.enricod.jcontextfree.gui.controllers.IMainController;

import javax.swing.SwingUtilities;

import com.google.inject.Guice;
import com.google.inject.Injector;
import javax.swing.UIManager;
import javax.swing.UIManager.LookAndFeelInfo;
import javax.swing.UnsupportedLookAndFeelException;

public class JContextFreeMain {

	public static void main(String[] args) {
		
		Runnable doCreateAndShowGui = new Runnable() {
			public void run() {
				createAndShowGUI();
			}
		};
		
		SwingUtilities.invokeLater(doCreateAndShowGui);
	}

	private static void createAndShowGUI() {

		JContextFreeModule jContextFreeModule = new JContextFreeModule();
		Injector injector = Guice.createInjector(jContextFreeModule);

		try {
			for (LookAndFeelInfo info : UIManager.getInstalledLookAndFeels()) {
				if ("Nimbus".equals(info.getName())) {
					UIManager.setLookAndFeel(info.getClassName());
					break;
				}
			}
		} catch (UnsupportedLookAndFeelException e) {
			// handle exception
		} catch (ClassNotFoundException e) {
			// handle exception
		} catch (InstantiationException e) {
			// handle exception
		} catch (IllegalAccessException e) {
			// handle exception
		}

		IMainController mainController = injector.getInstance(IMainController.class);
		mainController.startGui();

	}
}
